﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Demo061803
{
    class Stendt
    {
        private int id;
        private string name;
        private string sex;
        private int age;
        private string zhuangye;

        public Stendt(int id, string name, string sex, int age, string zhuangye)
        {
            this.id = id;
            this.name = name;
            this.sex = sex;
            this.age = age;
            this.zhuangye = zhuangye;
        }

        public int Id { get => id; set => id = value; }
        public string Name { get => name; set => name = value; }
        public string Sex { get => sex; set => sex = value; }
        public string Zhuangye { get => zhuangye; set => zhuangye = value; }

        public int Age 
        {
            get { return age; }
            set
            {
                if (value <= 0 || value >= 128)  //判断 写入的值是否满足if条件 如果是，赋值0
                {
                    Console.WriteLine("年龄非法！默认为0");
                    value = 0;
                }
                age = value;
            }
        }
        public Stendt() { }
        public void Output()
        {
            Console.WriteLine("学号：{0}，姓名：{1}，性别：{2}，年龄：{3}，专业信息：{4}",this.id,this.name,this.sex,this.age,this.zhuangye);

        }
    }
}
